import logging
from logging import handlers

logger = logging.getLogger("vpn-python-log") 
log_file = "/var/vpn_python.log"
fh = handlers.RotatingFileHandler(filename=log_file, maxBytes=1*1024*1024, backupCount=3, encoding="utf-8")
formatter = logging.Formatter('%(asctime)s %(filename)s-%(lineno)d %(levelname)s: %(message)s', 
                datefmt='%Y/%m/%d %H:%M:%S')
fh.setFormatter(formatter)
# fh.setLevel(logging.DEBUG)
console = logging.StreamHandler()
# console.setLevel(logging.DEBUG)

logger.addHandler(fh)
logger.addHandler(console)
logger.setLevel(logging.DEBUG)